<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>评测平台</title>
    <!--&lt;!&ndash;<meta name="viewport" content="width=device-width,initial-scale=1">&ndash;&gt;-->
    <meta name="viewport" content="width=320,maximum-scale=1.3,user-scalable=no">
    <!--js文件-->
    <script src="./js/jquery.min.js"></script>
    <script src="./js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="css/font.css">
    <!--样式文件-->
    <link rel="stylesheet" href="./css/bootstrap.min.css">
    <link rel="stylesheet" href="css/pingce.css">
</head>
<body>
<!--用户信息-->
<div id="heads">
    <div class="header">
        <div class="header-admin">
            <div class="header-pic">
                <img src="images/user.png">
            </div>
            <div class="header-txt">
                <P>65141414154545451X</P>
                <p>sfdafjfjakjgfjgalkgkagjgfgsfgssg</p>
            </div>
        </div>
    </div>
</div>

 <!--这是一个模板-->
 <div id="temp" style="display: none">
    <div class="panel blue" id="tr_table">
        <div class="panel-heading blues" >
            <h4 class="panel-title" >
                    <span class="cate_name">饮料</span>
                    <a class="drops"></a>
                </h4>
        </div>
        <div class="panel-collapse">
        <div class="panel-body" id="sec">
        <p>
            <span id="sec_name">分类：</span>
            <select   name='cate_desc' id="three_name">
                
            </select>
        </p>
        
        <p>
            <span id="sec_name2"> 规格:</span>
                <select class="capacity" id="three_name2" name="spec">
                        
                 </select>
        </p>
        <p id="par">
            <a onclick="advice(this)" class="onc">查看建议</a><span></span>
        </p>
        </div>
        </div>
    </div> 
    
</div>
<!--模板结束-->
<!--列表区域-->
<form action="/admin/submitdata" method="POST" onsubmit="return sub()">
   
    <div class="model-list">
            <div class="panel-group" id="accordion">
                     
             </div>
      <button type="submit">
        提交
        </button> 
        
    </div>
</form>
<script>
  
    $(function(){
        $.ajax({
            url:"/admin/menu",
            type:"get",
            dataType:"json",
            success:function(data){
                $.each(data,function(i,v){
                   
                    $("#temp #tr_table .cate_name").text(v.cate_name);//大类名
                    $("#temp #tr_table #par .onc").attr("id",v.cate_id);
                    $.each(v.childList,function(x,y){
                        if(x==0){
                            $("#sec_name").text(y.cate_name);//分类描述1
                            $("#three_name").text("");
                            $.each(y.childList,function(p,q){//描述选项1
                                $("#three_name").append("<option value="+q.cate_id+">"+q.cate_name+"</option>");
                            });
                        }else{
                            $("#sec_name2").text(y.cate_name);//分类描述2
                            $("#three_name2").text("");
                            $.each(y.childList,function(p,q){//描述选项2
                                $("#three_name2").append("<option value="+q.cate_name+">"+q.cate_name+"</option>");
                            });
                        }
                   });
                   //一级菜单挂接到模板下面
                   $("#tr_table").clone(true).insertBefore("#accordion");
                   
                });
            }
        });
    });
    $(document).ready(function () {
        $(".drops").html("收起 &nbsp;<i class='glyphicon glyphicon-chevron-up'></i>")
        $(".drops").click(function () {
            $(this).toggleClass("drop-up")
            $(this).parent().parent().siblings().toggleClass("god");
            if ($(this).hasClass("drop-up")) {
                $(this).html("展开 &nbsp;<i class='glyphicon glyphicon-chevron-down'></i>")
            }
            else {
                $(this).html("收起 &nbsp;<i class='glyphicon glyphicon-chevron-up'></i>")
            }
        })
    })
   function advice(a){
          $.ajax({
           url:"/admin/catedesc?cate_id="+a.id,
           type:"get",
           dataType:"json",
           success:function(data){
              var pare =  a.parentNode;
              var t1 = pare.firstElementChild;
              var t2 = pare.lastElementChild;
              t1.innerText = "下一条";
              t2.innerText = " "+data;
           }
       });
   }

   function sub(){
       alert("提交成功");
       return true;
   }
</script>
</body>
</html>